/**
 * Created by wuzebo on 2018/1/26.
 */
routerApp.directive("uiTable", function () {
  return {
    replace: true,
    restrict: 'ECMA',
    /*controller : ['$compile','$scope','$http',function($compile,$scope,$http){
      //内部传值
    }],*/
    template: '<div><div ui-grid="gridOptions" ui-grid-pagination ui-grid-edit></div></div>'
  }
});

;(function ($) {
  var g_option = function () {
      this.out = function () {
        //公共方法
      }
  };
  g_option.prototype ={
      init:function (url,b,c,searchBtn) {
        var _this = this;
          routerApp.controller(b,function ($scope, $http ,$rootScope) {
          $("#"+searchBtn).click(function () {//点击查询
              var obj_search ={ };
              $(c+" span input").each(function () {
                  var zz = $(this).attr("data-id");
                  obj_search[zz] = $(this).val();
              });
              $http({
                  method: 'POST',
                  url:getRequestUrl(url),
                  params:obj_search
              }).success(function successCallback(response) {
                  $scope.gridOptions.data = response;
              }).error(function () {
                  console.log("错误");
              });
          });
          $scope.gridOptions ={
              //columnDefs:_this.columns(),
              //paginationPageSizes:[5, 10, 25],
              //enableColumnMenu: true,
              // enableGridMenu: true,
              // enableSelectAll: true,
              //enableRowHeaderSelection : true, //是否显示选中checkbox框 ,默认为true
          };

          $scope.gridOptions.paginationPageSize = $rootScope.pageyy;
            // if(_this.clicks($scope)){
            //     _this.clicks($scope);
            // }
          $scope.anniu = function (a,b) {//回传数据
              $scope.objects[a] = $scope.objects;
              $scope.gridOptions.data.unshift($scope.objects[a]);
              $(b).modal('hide');
          };
          $scope.delet = function (index) {
              $scope.gridOptions.data.splice(index,1);
          };
          /*$http({ //通过标示符查询方法
             method:'post',
             url:'http://localhost:8082/drgs/query',
             data:{queryId:"DRG_EXA_MONTH",hospId:"286"}
           }).success(function(req){
               console.log(req);
           }).error(function () {
               console.log("错误");
           });*/
        });
      },
      page:function (e) {//分页
          angular.module('page_aa', []).run(function ($rootScope) {
              $rootScope.pageyy = e;
          });
      },
      columns:function () { },//提取头部栏目
  };
  window.g_option = g_option;
})(jQuery);
